#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e6 + 5;

mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
int n, k;
int a[N];
void f(int n) {
  if (__builtin_popcount(n) == 1) {
    rep(i, 1, n) a[i] = k;
    return;
  }
  int h = 20;
  while (h >= 0 && (n & (1 << h)) == 0) h--;
  f(n ^ (1 << h));
  rep(i, 1, n / 2) a[n + 1 - i] = a[i];
}
void solve() {
  cin >> n >> k;
  rep(i, 1, n) a[i] = 0;
  f(n);
  rep(i, 1, n) cout << a[i] << ' ';
  cout << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}